package com.zzty.zzlp.socket;

import org.springframework.web.socket.WebSocketSession;

import javax.websocket.Session;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by dcui013 on 8/11/2017.
 */
public class SessionUtils {
    public static Map<String, WebSocketSession> clients = new ConcurrentHashMap<>();

    public static void put(String userId,  WebSocketSession session){
        clients.put(userId, session);
    }

    public static WebSocketSession get(String userId){
        return clients.get(userId);
    }

    public static void remove(String userId){
        clients.remove(userId);
    }


    public static boolean hasConnection(String userId) {
        return clients.containsKey(userId);
    }



}
